//
//  HFStatusCellBottomView.swift
//  sinaMicroBlog
//
//  Created by mac on 15/11/18.
//  Copyright © 2015年 mac. All rights reserved.
//

import UIKit

class HFStatusCellBottomView: UIView {
    
    @objc private func retweetedBtnDidClcik() {
        let temp = HFTempViewController()
        retweetedButton.navController()?.pushViewController(temp, animated: true)
    }

    //重写实例化方法
    override init(frame: CGRect){
        super.init(frame: frame)
        backgroundColor = UIColor(white: 0.98, alpha: 1.0)
        setupUI()
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    private func setupUI() {
        addSubview(retweetedButton)
        addSubview(composeButton)
        addSubview(likeButton)
        
        let rightSep = sepView()
        addSubview(rightSep)
        let leftSep = sepView()
        addSubview(leftSep)
        
        //添加约束
        let w: CGFloat = 0.5
        let scale = 0.4
        retweetedButton.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(snp_left)
            make.top.equalTo(snp_top)
            make.height.equalTo(snp_height)
        }
        leftSep.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(retweetedButton.snp_right)
            make.height.equalTo(retweetedButton.snp_height).multipliedBy(scale)
            make.centerY.equalTo(self.snp_centerY)
            make.width.equalTo(w)
        }
        composeButton.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(retweetedButton.snp_right)
            make.top.equalTo(snp_top)
            make.height.equalTo(snp_height)
            make.width.equalTo(retweetedButton.snp_width)
        }
        rightSep.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(composeButton.snp_right)
            make.height.equalTo(retweetedButton.snp_height).multipliedBy(scale)
            make.centerY.equalTo(self.snp_centerY)
            make.width.equalTo(w)
        }
        
        likeButton.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(composeButton.snp_right)
            make.top.equalTo(snp_top)
            make.right.equalTo(snp_right)
            make.height.equalTo(snp_height)
            make.width.equalTo(composeButton.snp_width)
        }
        retweetedButton.addTarget(self, action: "retweetedButtonClick", forControlEvents: .TouchUpInside)
    }
    
    //懒加载子控件
    //分割线
    private func sepView() ->UIView {
        let sepView = UIView()
        sepView.backgroundColor = UIColor.darkGrayColor()
        return sepView
    }
    //转发,评论,赞
    private lazy var retweetedButton = UIButton(title: "转发", backImage: nil, titleColor: UIColor.darkGrayColor(), image: "timeline_icon_retweet", size: 10)
    private lazy var composeButton = UIButton(title: "评论", backImage: nil, titleColor: UIColor.darkGrayColor(), image: "timeline_icon_comment", size: 10)
    private lazy var likeButton = UIButton(title: "赞", backImage: nil, titleColor: UIColor.darkGrayColor(), image: "timeline_icon_unlike", size: 10)
    
    
}
